<?php
/**
 * Created by PhpStorm.
 * User: 戎大富
 * Date: 2019/12/27
 * Time: 13:46
 */

namespace app\admin\controller;
use think\Db;
use think\Request;
class Sort extends Base {
    /**
     * 列表展示
     * @return mixed|\think\response\Json
     */
    public function index(){
        if(request()->isAjax()){
            extract(input());
            $NowPage = input('page') ? input('page') : 1;
            $limits = input("limit") ? input("limit") : 10;
            $count = Db::name('sort')
                ->count();// 获取总条数
            $lists = Db::name('sort')
                ->page($NowPage,$limits)
                ->select();
            return json(['code' => 220, 'msg' => '', 'count' => $count, 'data' => $lists]);
        }
        return $this->fetch();
    }
        /**
         * 修改排序
         * @return \think\response\Json
         */
        public function sort(){
            $param = input('');
            $res = Db::table('up_sort')->where('sort_id', $param['id'])->setField('sort', $param['value']);
            if($res){
                return json(['code' => 200, 'msg' => '修改成功']);
            }else{
                return json(['code' => 100, 'msg' => '修改失败']);
            }
        }
}